<template>
  <div>
    <ElForm inline>
      <ElFormItem label="贷款种类">
        <ElInput v-model="queryCondition.materialCodeLike"></ElInput>
      </ElFormItem>
      <ElFormItem>
        <ElButton icon="Search" type="primary" @click="queryByCondition(1)"></ElButton>
      </ElFormItem>
    </ElForm>

    <ElTable :border="true" stripe :data="pageInfo.results">
      <ElTableColumn prop="loanCode" label="贷款编号"></ElTableColumn>
      <ElTableColumn prop="billState" label="贷款状态"></ElTableColumn>
      <ElTableColumn prop="materialCode" label="贷款种类"></ElTableColumn>
      <ElTableColumn prop="applyAmount" label="贷款金额"></ElTableColumn>
      <ElTableColumn prop="bizCard" label="对公银行卡"></ElTableColumn>
      <ElTableColumn prop="bizLicense" label="营业执照"></ElTableColumn>
      <ElTableColumn label="operation">
        <template #default="{ row }">
          <ElButton size="small" type="success" @click="submit(row)">正式提交</ElButton>
        </template>
      </ElTableColumn>
    </ElTable>
    <ElPagination
      background
      layout="prev, pager, next"
      :total="pageInfo.total"
      :page-size="queryCondition.pageSize"
      :current-page="queryCondition.pageNum"
      @current-change="queryByCondition"
    />
  </div>
</template>
<script lang="ts" setup>
/*      "loanCode": "LN20230927000002",
            "billState": "toSubmit",
            "loanApplier": "RedCompany",
            "materialCode": "DK20230925000006",
            "applyAmount": 22220.00,
            "loanBank": "AppleBank",
            "firstAuditTime": null,
            "firstAuditWord": null,
            "secondAuditTime": null,
            "secondAuditWord": null,
            "version": 0,
            "updateTime": "2023-09-27T15:30:05",
            "firstAuditor": "",
            "bizCard": "sss.png",
            "bizLicense": "zzz.png" */
const pageInfo = reactive({
  total: 0,
  results: [] as Array<any>
})
const queryCondition = reactive({
  pageNum: 1,
  pageSize: 3,
  loanApplier: '',
  firstAuditor: '',
  bankName: '',
  materialCodeLike: ''
})
const queryByCondition = async (pageNum?: number) => {
  if (pageNum) {
    queryCondition.pageNum = pageNum
  }
  const res = await axios({
    method: 'post',
    url: 'http://localhost:9091/loanBill/queryForCompany',
    data: queryCondition
  })
  pageInfo.total = res.data.total
  pageInfo.results = res.data.records
}
onMounted(() => {
  queryByCondition(1)
})
const submit = async (row: any) => {
  const res = await axios({
    method: 'put',
    url: 'http://localhost:9091/loanBill/submit/' + row.loanCode
  })
  queryByCondition()
}
</script>
<style lang="scss" scoped></style>
